#include <string>
#include <iostream>
#include "server.hpp"

#define BUFFER_TEST

#ifdef LOG_DEF

#define INFO_LEVEL 0
#define DBG_LEVEL 1
#define ERR_LEVEL 2
#define FATAL_LEVEL 3
#define LOG_LEVEL DBG_LEVEL

#define LOG(level, format, ...) { \
    if (level >= LOG_LEVEL) { \
        char tmTmp[32]; tmTmp[0] = 0; \
        time_t t = (time_t)time(nullptr); \
        strftime(tmTmp, 31, "%H:%M:%S", localtime(&t)); \
        fprintf(stdout, "[%s:%d] %s # " format "\n", __FILE__, __LINE__, tmTmp, ##__VA_ARGS__); \
    } \
}

#define INFO_LOG(format, ...) LOG(INFO_LEVEL, format, ##__VA_ARGS__)
#define DBG_LOG(format, ...) LOG(DBG_LEVEL, format, ##__VA_ARGS__)
#define ERR_LOG(format, ...) LOG(ERR_LEVEL, format, ##__VA_ARGS__)
#define FATAL_LOG(format, ...) LOG(FATAL_LEVEL, format, ##__VA_ARGS__)

#endif

#ifdef BUFFER_TEST

int main()
{
    // Buffer buf;

    // for (int i = 0; i < 500; ++i) {
    //     std::string inStr = "Hello!!!" + std::to_string(i) + '\n';
    //     buf.WriteAndPush(inStr);
    // }

    // while (buf.GetReadableSpace() > 0) {
    //     std::cout << buf.GetLineAndPop();
    // }

    // std::string inBuf("Hello World!!!");

    // buf.WriteAndPush(inBuf);
    // std::cout << buf.GetReadableSpace() << std::endl;
    // char bufs[1024]; bufs[0] = '\0';
    // buf.ReadAndPop(bufs, 5);
    // bufs[5] = 0;
    // std::cout << bufs << std::endl;
    // std::cout << buf.GetReadableSpace() << std::endl;
    // std::cout << buf.ReadAndPop(buf.GetReadableSpace()) << std::endl;
    // std::cout << buf.GetReadableSpace() << std::endl;

    // // std::string res = buf.ReadAndPop(inBuf.size());
    // // std::cout << res << std::endl;
    // // std::cout << buf.GetReadableSpace() << std::endl;
    // Buffer buf1(buf);
    // std::cout << buf1.ReadAndPop(inBuf.size()) << std::endl;


    return 0;
}

#endif